package com.anbinh.doctor.adapter;

import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;

import com.anbinh.doctor.R;
import com.anbinh.doctor.model.ItemMeu;

public class SelectDayAdapter extends ArrayAdapter<ItemMeu> {
	private int resource;
	private LayoutInflater layoutInflater;
	private List<ItemMeu> listData;
	private int idCheked;

	public SelectDayAdapter(Context mContext, int resource,
			List<ItemMeu> models, int idChecked) {
		super(mContext, resource, models);
		this.resource = resource;
		this.listData = models;
		layoutInflater = LayoutInflater.from(mContext);
		this.idCheked = idChecked;
	}

	public class ViewHolder {
		public CheckBox lblTitle;
		public ImageView icon;

	}

	@Override
	public ItemMeu getItem(int position) {
		return listData.get(position);
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = layoutInflater.inflate(resource, null, true);

			viewHolder.lblTitle = (CheckBox) convertView
					.findViewById(R.id.rdGroup);

			viewHolder.icon = (ImageView) convertView.findViewById(R.id.icon);

			convertView.setTag(viewHolder);

		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		ItemMeu item = getItem(position);
		viewHolder.lblTitle.setChecked(item.isChecked());
		Log.d("lblTitle", "lblTitle");
		if(item.getRegId()!=R.id.chu_nhat){
			viewHolder.lblTitle.setText("Thứ "+item.getTitle());
		}else{
			viewHolder.lblTitle.setText(item.getTitle());
		}

		return convertView;
	}
}
